//
//  SJNetRequest.h
//  鼎立华服
//
//  Created by 中企互联 on 2018/1/4.
//  Copyright © 2018年 中企互联. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

#define kTimeOutInterval 5.f // 请求超时的时间

/*
 *   请求成功数据Block
 */
typedef void (^SuccessRequest) (id success);
/*
 *   请求失败错误信息Block
 */
typedef void (^FailRequest)(id fail);
/*
 *   网络不通执行下面Block
 */
typedef void (^NetStateIsNo)(void);


@interface SJNetRequest : NSObject

/***
 *   检验网络状态，是否连接网络，调用此方法即可返回BOOL类型来判断
 ***/
+(BOOL)IsConnectToNet;

#pragma GET 请求
/***
 *   GET 请求
 requestUrl 参数:接口地址
 params 参数:接口地址所需参数 例如:接口地址?type=1&name=abc
 ***/
+(void)GETRequest:(NSString *)requestUrl
       WithParams:(NSDictionary *)params
      WithSuccess:(SuccessRequest)success
         WithFail:(FailRequest)fail
     WithNetState:(NetStateIsNo)nonet;

#pragma POST 请求
/***
 *   POST 请求
 requestUrl 参数:接口地址
 params 参数:接口地址所需参数 例如:接口地址?type=1&name=abc
 ***/
+(void)POSTRequest:(NSString *)requestUrl
        WithParams:(NSDictionary *)params
       WithSuccess:(SuccessRequest)success
          WithFail:(FailRequest)fail
      WithNetState:(NetStateIsNo)nonet;

#pragma 上传图片
+(void)POSTPICRequst:(NSString *)requestUrl
          WithParams:(NSDictionary *)params
       WithImageData:(NSData *)imageData
        WithDataFile:(NSString *)dataFile
       WithImageName:(NSString *)imageName
         WithSuccess:(SuccessRequest)success
            WithFail:(FailRequest)fail
        WithNetState:(NetStateIsNo)nonet;

@end
